﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace DataSources
{
    public class Utils
    {
        public static string GridCoordinate2Hash(System.Drawing.Point gridCoordinate)
        {
            // Google standard hash format
            int column = gridCoordinate.X;
            int row = gridCoordinate.Y;
            return "R" + row.ToString() + "C" + column.ToString();
        }

        public static System.Drawing.Point Hash2GridCoordinate(string hash)
        {
            string columnPart = hash.Substring(hash.IndexOf('C') + 1);
            string rowPart = hash.Substring(hash.IndexOf('R') + 1, hash.IndexOf('C') - 1);
            int column = Convert.ToInt32(columnPart);
            int row = Convert.ToInt32(rowPart);
            return new System.Drawing.Point(column, row);
        }
    }
}
